﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Project
{
    public partial class SP统计 : Form
    {
        public SP统计()
        {
            InitializeComponent();
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            
        }

        private void SP统计_Load(object sender, EventArgs e)
        {
            this.dataGridView1.AutoGenerateColumns = false;
            string sql = "select t.*,r.RmId,c.CeName,o.CyName from TongJioo t,RoomInfo r,CetaeInfo c ,Commodity o where t.CsoRoom=r.RmId and t.CsoName=c.CeId and t.SsoName=o.CyId";
            this.dataGridView1.DataSource = FrmHotel.DBHelper.SelectForTable(sql);
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            this.dataGridView1.AutoGenerateColumns = false;
            string sql = "select * from TongJioo where 1=1";
           string  id = this.textBox1.Text;
            if(!string.IsNullOrEmpty(id))
            {
                sql += string.Format(" and CsoRoom like '%{0}%'",id);
            }
            this.dataGridView1.DataSource = FrmHotel.DBHelper.SelectForTable(sql);
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            this.dataGridView1.AutoGenerateColumns = false;
            string sql1 = "select * from TongJioo where 1=1";
            string name = this.textBox2.Text;
            if(!string.IsNullOrEmpty(name))
            {
                sql1 += string.Format(" and SsoName  like '%{0}%'",name);
            }
            this.dataGridView1.DataSource = FrmHotel.DBHelper.SelectForTable(sql1);
        }
    }
}
